<template>
  <div>
    <div class="search-c">
      <div class="search">
        <van-search
          v-model="value"
          background="#23262d"
          placeholder="搜影片、影院、影人"
          @search="onSearch"
          left-icon
        />
        <div class="cancel" @click="onCancel">取消</div>
      </div>
      <div class="wrapper">
        <div class="searchInfo">
          <div>
            <span>影火虫热搜</span>
          </div>
          <ul>
            <li>
              <p class="hot">一条狗的使命</p>
              <p>哥斯拉2:怪兽之王</p>
            </li>
            <li>
              <p class="new">大鱼海棠</p>
              <p>下一任：前任</p>
            </li>
            <li>
              <p>人间.小团圆</p>
              <p class="new">音乐家</p>
            </li>
            <li>
              <p class="rec">爱你直到世界尽头</p>
              <p class="more">
                更多热搜
                <van-icon name="arrow" />
              </p>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BScroll from "better-scroll";
//  npm install better-scroll -- save
export default {
  data() {
    return {
      value: "",
      bScroll: "",
    };
  },
  created() {
    // Ajax获取数据填充之后不能滚动,需要在dom更新之后调用this.bScroll.refresh();
    // axios({
    //   url:"xxx",
    //   method:"get",
    //   params:{
    //     id:1
    //   }
    // }).then((res)=>{
    //   this.list=res.data;
    //    this.$nextTick(() => {
    //   //dom更新之后执行的回调
    //   this.bScroll.refresh();
    // });
    // })
  },
  mounted() {
    //  滚动的前提条件: content元素高度/宽度大于wrapper的高度/宽度
    this.bScroll = new BScroll(document.querySelector(".wrapper"), {
      // probeType为3, 只要是滚动就实时派发scroll事件
      probeType: 3, //只要是滚动，就监听
      //默认不能触发点击事件,如果需要点击事件配置click为true,
      click: true,
    });
  },
  methods: {
    onSearch(val) {
      // console.log(val);
    },
    onCancel() {
      this.$router.go(-1)
    },
  },
};
</script>
<style lang="scss" scoped>
.wrapper {
  height: 200px;
}

.search-c {
  width: 680px;
  margin: 0 auto;
}
.search {
  width: 100%;
  margin-top: 16px;
  display: flex;
}
.van-search {
  width: 600px;
  caret-color: #fff;
}
.cancel {
  margin-top: 20px;
  margin-left: 5px;
  font-size: 32px;
  color: #f7f7f7;
  opacity: 0.87;
}
.van-search__content {
  height: 60px;
  box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.33);
  border-radius: 26px;
  color: #fff;
  background: #33363d url(~@/assets/images/search/s1.png) no-repeat 32px 18px /28px;
  /deep/.van-field__body {
    margin-top: 10px;
    margin-left: 80px;
    font-size: 28px;
    color: #7a7a7a;
    opacity: 0.67;
    input {
      color: #7a7a7a;
    }
  }
}

.searchInfo {
  margin-left: 18px;
  img {
    width: 46px;
    height: 46px;
    vertical-align: -8px;
  }
  span {
    opacity: 0.8;
    font-size: 30px;
    color: #dfdfdf;
    margin-left: 10px;
  }
  p {
    width: 50%;
    font-size: 31px;
    color: #dfdfdf;
  }
  ul {
    margin-top: 15px;
    li {
      height: 45px;
      display: flex;
      justify-content: space-between;
      & ~ li {
        margin-top: 35px;
      }
    }
  }
  .more {
    color: #f1a363;
    .van-icon {
      vertical-align: -4px;
    }
  }

  @mixin mi {
    font-size: 20px;
    color: #dfdfdf;
    display: inline-block;
    width: 34px;
    height: 33px;
    text-align: center;
    margin-left: 5px;
    line-height: 33px;
    border-radius: 5px;
    vertical-align: 2px;
  }

  .hot::after {
    content: "沸";
    @include mi();
    background-image: linear-gradient(135deg, #b0469d 0%, #6148aa 100%);
  }
  .new::after {
    content: "新";
    @include mi();
    background-image: linear-gradient(135deg, #eb6e75 0%, #f7a653 100%);
  }
  .rec::after {
    content: "荐";
    @include mi();
    background-image: linear-gradient(135deg, #322495 0%, #3138ac 100%);
  }
}
</style>
